home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _F164243DB45C455BA025F1933029544C < prev    next >
Encoding:
Text File  |  2004-01-06  |  2.1 KB  |  51 lines

  1.       #include "../CGVPMacro.csi"
  2.  
  3.       PS20Only
  4.  
  5.       MainInput { uniform sampler2D baseMap : texunit0,
  6.                   uniform sampler2D bumpMap : texunit1,
  7.                   uniform samplerCUBE normCubeMapLV : texunit2,
  8.                   uniform samplerCUBE normCubeMapHA : texunit3,
  9.                   uniform samplerCUBE projMap : texunit4,
  10.                   uniform sampler2D attenMap : texunit5,
  11.                   uniform samplerCUBE envMap : texunit6,
  12.                   uniform float4 Ambient,
  13.                   uniform float4 Reflect,
  14.                   uniform float4 Diffuse,
  15.                   uniform float4 Specular }
  16.       DeclarationsScript
  17.       {
  18.         OUT_T0_T1_T2_T3_T4_T5_T6_C0
  19.         FOUT
  20.       }
  21.       CoreScript
  22.       {
  23.         // load the decal
  24.         half4 decalColor = tex2D(baseMap, IN.Tex0.xy);
  25.         // load the bump normal
  26.         float4 bumpNormal = 2*(tex2D(bumpMap, IN.Tex1.xy)-0.5);
  27.         // load the projector filter map
  28.         half4 projColor = texCUBE(projMap, IN.Tex4.xyz);
  29.         // load the environment map
  30.         half4 envColor = texCUBE(envMap, IN.Tex6.xyz);
  31.         half atten = saturate((2*(IN.Color.b-0.5)) * -(2*(IN.Color.b-0.5)) + (1-tex2D(attenMap, IN.Tex5.xy).b));
  32.  
  33.         // Light vector from normalization cube-map
  34.         float4 lVec = 2*(texCUBE(normCubeMapLV, IN.Tex2.xyz)-0.5);
  35.         // Half angle vector from normalization cube-map
  36.         float4 hVec = 2*(texCUBE(normCubeMapHA, IN.Tex3.xyz)-0.5);
  37.         
  38.         half NdotL = saturate(dot(lVec.xyz, bumpNormal.xyz));
  39.         half NdotH = saturate(dot(hVec.xyz, bumpNormal.xyz));
  40.         half3 dif = (decalColor.xyz * NdotL * atten * Diffuse.xyz * projColor.xyz) * 2;
  41.         half  specVal = saturate((NdotH - 0.75)*4);
  42.         specVal = specVal * specVal;
  43.         half3 spec = (specVal * atten * projColor.xyz * Specular.xyz) * 2;
  44.         half3 amb = lerp(decalColor.xyz*Ambient.xyz, envColor.xyz, Reflect.x);
  45.  
  46.         // finally add them all together
  47.         OUT.Color.xyz = amb + dif + spec;
  48.         OUT.Color.w = decalColor.w * Ambient.w;
  49.       }
  50.  
  51.